package com.nineclock.system.feign;

import com.nineclock.common.entity.PageResult;
import com.nineclock.common.entity.Result;
import com.nineclock.system.dto.SysCompanyUserDTO;
import com.nineclock.system.dto.SysUserDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.List;

/**
 * @author 黑马程序员
 * @Company http://www.ithiema.com
 * @Version 1.0
 */
@FeignClient("sys-service")
public interface SysUserFeign {

    @GetMapping("/user/query")
    public Result<SysUserDTO> queryUser(@RequestParam("username") String username);

    /**
     * 在feign接口中 get请求，所有的参数都必须加 @RequestParam
     * @param companyId
     * @param userId
     * @return
     */
    @GetMapping("/companyUser/query")
    public Result<List<SysCompanyUserDTO>> queryCompanyUser(
            @RequestParam(value = "companyId",required = false) Long companyId,
            @RequestParam(value = "userId",required = false) Long userId);


    @GetMapping("/user/findById")
    public Result<SysCompanyUserDTO> findUserById(@RequestParam("userId") Long userId);

    //查询企业ID下的所有部门ID
    @GetMapping("/organization/department/top")
    public Result<List<Long>> queryDepartmentIds();

    /**
     * 查询指定部门集合下员工的数量
     */
    @GetMapping("/organization/department/membernum")
    public Result<Integer> queryUserCountByDepartmentId(@RequestParam("departmentIds") List<Long> departmentIds);


    /**
     * 根据员工id获得部门从低到高级别的部门ID数组
     * @param
     * @return
     */
    @GetMapping("/department/allDepId/{companyUserId}")
    public Result<List<Long>> queryDepartmentsByUserId(@PathVariable("companyUserId") Long companyUserId);

    @GetMapping("/companyUser/queryAll")
    public Result<List<SysCompanyUserDTO>> findAllCompanyUser();

    //根据企业ID查询企业的主管理员信息
    @GetMapping("/companyUser/queryAdminByCompanyId")
    public Result<SysCompanyUserDTO> queryAdminByCompanyId(@RequestParam(value = "companyId", required = false)Long companyId);

    @GetMapping("/companyUser/listSignAllUser")
    public Result<SysCompanyUserDTO> findCompanyUserId(@RequestParam("companyUserId") Long companyUserId);

    //上传图片到oss
    @PostMapping("/company/uploadOSS")
    public Result<String> uploadCompanyLogo(MultipartFile file) throws IOException;

    @GetMapping("/companyUser/sign")
    Result<PageResult<SysCompanyUserDTO>> queryPageResult(@RequestParam("page") String page, @RequestParam("pageSize") String pageSize);


    @GetMapping("/companyUser/pagingCollaborations")
    public Result<SysCompanyUserDTO> findCompanyUserById (@RequestParam("userId") Long userId);

}
